home *** CD-ROM | disk | FTP | other *** search
- Path: keats.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: Segmentation Fault ???
- Date: 10 Mar 1996 10:31:15 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4hv75jINNpss@keats.ugrad.cs.ubc.ca>
- References: <4hsa7i$en3@wraith.its.uow.edu.au> <4huis1$cm2@ccshst05.cs.uoguelph.ca>
- NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
-
- In article <4huis1$cm2@ccshst05.cs.uoguelph.ca>,
- Toby K Hay <thay@uoguelph.ca> wrote:
- >Theeradech Paopeng (tp02@wraith.its.uow.edu.au) wrote:
- >: Hello to all.
- >: I'm here to ask you guys about the "Segmentation Fault".
- >: I was run my program on Unix and I got run_time_error say that "Segmentation
- >: Fault". I really no idea how to fix that problem. One more thing I have to tell to fix that problem. One more thing I have to tell
- >
- >This is a coincidence. I moved a running ANSI C program from Turbo C on
- >my PC to a multi-processor Silicon Graphics UNIX machine yesterday (my
- >first try at running C on anything but a PC) and got the same error.
- >Retrying invoked a "Bus Error". I assumed that my abysmal ingnorance of
- >UNIX was causing me to omit essential switches from the command line or
- >something of that nature, and resolved to ask on an SGI newsgroup, and to
- >ask the system administrator for guidance after the weekend.
- >This is all off topic for this group but, seeing the title, I couldn't
- >resist describing my difficulties too.
-
- It means that you are making errors in your code that the Turbo C environment
- doesn't catch. The bus error is likely caused by invoking
- implementation-specific behavior that is in contravention to standard C:
- converting a pointer to one that has a stricter alignment. On many of the
- processors used in UNIX workstations, the address of a long word has to be
- divisible by four. On a 68000 processor, the address of a 16-bit word has to be
- divisible by two.
-
- If you fail to meet these alignment restrictions, the hardware will trigger an
- exception, and the UNIX kernel will send a SIGBUS signal to your program.
-
- The SIGBUS signal can also be generated by accesses to certain kinds of virtual
- memory pages, and can be artifically triggered using the raise() function,
- though I doubt that either of these scenarios is the case in your program.
-
- A ``segmentation fault'', (SIGSEGV signal), on the other hand, is caused by
- accessing illegal memory, such as dereferencing a null pointer, reaching past
- the limits of your malloc heap or stack and so forth.
-
-
-
- --
-
-